package com.wzy.java;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *@author:liyongyong
 *@description: Stream流中filter,skip,limit,distinct方法学习
 *@date 2019/2/14
 */
public class test9 {
    public static void main(String[] args){
        //打印出集合中的偶数
        List<Integer> list = Arrays.asList(1,2,3,4,5,6,7,8);
        list.stream().filter(num->num%2==0).forEach(System.out::println);
        //打印集合中的字符串，去掉重复的字符串
        List<String> string = Arrays.asList("abc","happy","hello","world","abc","hello");
        string.stream().distinct().forEach(System.out::print );
        //打印集合跳过前两个的前三个元素
        List<Integer> list1 = Arrays.asList(1,2,3,4,5,6,7,8);
        list1.stream().skip(2).limit(3).forEach(System.out::print);

        if (list instanceof List){
            System.out.println(true);
        }
    }
}

